import { Controller } from "../../mvc/core/Controller";
import { IPackController } from "./interfaces/IPackController";
import { PackExtendProxy } from "../proxy/PackExtendProxy";
import { DataEvent } from "../events/DataEvent";
import { ItemData } from "../resource/info/ItemData";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { EPlayerItemPosType } from "../../../Message/Public/EPlayerItemPosType";
import { Cache } from "../cache/Cache";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { DragDropData } from "../view/pack/DragDropData";
import { GameProxy } from "../mvc/GameProxy";
import { PackItem } from "../view/pack/PackItem";
import { PackCache } from "../cache/PackCache";
import { ItemEffectType } from "../rules/ItemEffectType";
import { PackWallet } from "../view/pack/PackWallet";
import { WindowEvent } from "../../component/window/WindowEvent";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { IPackModule } from "../../../modules/interfaces/IPackModule";
import { IView } from "../../mvc/interfaces/IView";
import { PackModule } from "../../../modules/PackModule";
import { GuideTipsManager } from "../manager/GuideTipsManager";
import { SystemSetter } from "../view/system/SystemSetter";
import { ShopOperType } from "../view/shop/ShopOperType";
import { ECategory } from "../../../Message/Public/ECategory";
import { ItemsUtil } from "../view/shortcuts/item/ItemsUtil";
import { ConstConfig } from "../resource/ConstConfig";
import { AutoGuideType } from "../view/common/guide/AutoGuideType";
import { HTMLUtil } from "../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../resource/ColorConfig";
import { CursorManager } from "../manager/CursorManager";
import { GameController } from "../mvc/GameController";
import { PulseSharedObject } from "../view/player/PulseSharedObject";
import { MsgTipInfo } from "../model/MsgTipInfo";
import { PackFullTips } from "../view/pack/PackFullTips";
import { Global } from "../../../com/gengine/global/Global";
import { GameUI } from "../view/mainUI/GameUI";
import { ModuleType } from "../view/common/ModuleType";
import { FlyToNavbarTool } from "../view/award/FlyToNavbarTool";
import { GlobalClass } from "../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../resource/ImagesConst";
import { ItemCoolDownUtil } from "../view/pack/ItemCoolDownUtil";
import { SDrugCanUseDtMsg } from "../../../Message/Game/SDrugCanUseDtMsg";
import { LayerManager } from "../manager/LayerManager";
import { PackPosTypeCache } from "../cache/PackPosTypeCache";
import { Alert } from "../../../com/mui/controls/Alert";
import { SActiveToClient } from "../../../Message/Public/SActiveToClient";
import { TitleInfo } from "../resource/info/TitleInfo";
import { SpecialRewardItemInfo } from "../resource/info/SpecialRewardItemInfo";
import { IEntity } from "../scene/player/IEntity";
import { UserPlayer } from "../scene/player/entity/UserPlayer";
import { CDBackPackItem } from "../cache/CDItem/CDBackPackItem";
import { BuffInfo } from "../view/avatar/BuffInfo";
import { PetEventName } from "../view/pet/PetEventName";
import { EItemUpdateOper } from "../../../Message/Game/EItemUpdateOper";
import { SmeltConfig } from "../resource/SmeltConfig";
import { GuildEventName } from "../view/guild/GuildEventName";
import { GameConst } from "../../component/gconst/GameConst";
import { MagicWeaponUtil } from "../view/magicWeapon/MagicWeaponUtil";
import { PetUtil } from "../view/pet/info/PetUtil";
import { TitleConfig } from "../resource/TitleConfig";
import { SpecialRewardItemConfig } from "../resource/SpecialRewardItemConfig";
import { DateParser } from "../../common/tools/DateParser";
import { ThingUtil } from "../scene/layer/utils/ThingUtil";
import { EntityUtil } from "../scene/layer/utils/EntityUtil";
import { SoundManager } from "../../common/sound/SoundManager";
import { SoundTypeConst } from "../../common/sound/SoundTypeConst";
import { RolePlayer } from "../scene/player/entity/RolePlayer";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { CheckBoxWin } from "../view/common/alertwins/CheckBoxWin";
import { GlobalStyle } from "../../common/global/GlobalStyle";
import { EquipmentUtil } from "../view/common/util/EquipmentUtil";
import { MountConfig } from "../resource/MountConfig";
import { ESex } from "../../../Message/Public/ESex";
import { IWareHouseModule } from "../../../modules/interfaces/IWareHouseModule";
import { SBagCapacityChangeMsg } from "../../../Message/Game/SBagCapacityChangeMsg";
import { BackPackWareHouseMoveType } from "../view/pack/define/BackPackWareHouseMoveType";
import { PackProxy } from "../proxy/PackProxy";
import { GuideTips } from "../view/guide/GuideTips";
import { OK } from "../../../Alert/OK";
type int = number;
//class PackController
    
    export  class PackController extends Controller implements IPackController
    {
        constructor()
        {
            
            super();this._packExtendProxy = new PackExtendProxy();
            this.Init();
            return;
        }

        /* internal  */onFastUserExtendItemHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (this._guideUid && this._guideUid == loc1.uid) 
            {
                this._guideUid = "";
                this._packModule.cacelPackIndexGuide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideItemUsed, loc1));
            }
            this.fastUseExtendItem(loc1);
            return;
        }

        /* internal  */fastUseExtendItem(arg1: ItemData): void
        {
            var loc6=null;
            if (!arg1) 
            {
                return;
            }
            var loc1=arg1.uid;
            var loc2=EPlayerItemPosType._EPlayerItemPosTypeBag;
            var loc3=EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar;
            var loc4=Cache.instance.pack.backPackCache.getIndexByUid(loc1);
            var loc5;
            if ((loc5 = Cache.instance.pack.backPackExtendPackCache.getFirstNullItemIndex()) == -1) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40032));
            }
            else 
            {
                loc6 = new DragDropData(loc2, loc3, loc1, loc4, loc5 + 1, null, null);
                GameProxy.packExtendProxy.move(loc6);
            }
            return;
        }

        /* internal  */fastMoveItemToWareHuse(arg1: DataEvent): void
        {
            var loc6=0;
            var loc8=0;
            var loc9=null;
            var loc1=arg1.data as PackItem;
            if (!loc1.itemData) 
            {
                return;
            }
            var loc2=loc1.itemData;
            var loc3=loc2.uid;
            var loc4=loc2.posType;
            var loc5=EPlayerItemPosType._EPlayerItemPosTypeWarehouse;
            if (loc4 != EPlayerItemPosType._EPlayerItemPosTypeStoneBag) 
            {
                if (loc4 != EPlayerItemPosType._EPlayerItemPosTypeAmuletBag) 
                {
                    loc6 = Cache.instance.pack.backPackCache.getIndexByUid(loc3);
                }
                else 
                {
                    loc6 = Cache.instance.pack.magicWeaponPackCache.getIndexByUid(loc3);
                }
            }
            else 
            {
                loc6 = Cache.instance.pack.stonePackCache.getIndexByUid(loc3);
            }
            var loc7;
            if ((loc7 = Cache.instance.pack.wareHousePackCache.getFirstNullItemIndex()) == -1) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40033));
            }
            else 
            {
                loc8 = loc7 + 1;
                loc9 = new DragDropData(loc4, loc5, loc3, loc6, loc8, null, null);
                GameProxy.wareHouseProxy.move(loc9);
            }
            return;
        }

        /* internal  */openBackPackExtendItem(arg1: DataEvent): void
        {
            GameProxy.packExtendProxy.openExtendItem(PackCache.Type_BackPackExtend);
            return;
        }

        /* internal  */onPackItemCoolDownHandler(arg1: DataEvent): void
        {
            var loc5=null;
            var loc1=arg1.data as Object;
            var loc2=loc1["uid"];
            var loc3=Cache.instance.pack.backPackCache.getIndexByUid(loc2);
            var loc4;
            if (loc4 = Cache.instance.pack.backPackCache.getItemDataByIndex(loc3) as ItemData) 
            {
                if ((loc5 = cache.timeCdCache.getCdTime(loc4)) && loc5.isCoolDown == false) 
                {
                    loc5.startCoolDown();
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ItemUse, loc5));
                }
            }
            return;
        }

        /* internal  */backPackCodeItemEffect(arg1: DataEvent): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=0;
            if (this.initView()) 
            {
                loc1 = Cache.instance.pack.backPackCache.getIndexByCode(arg1.data as int);
                Cache.instance.itemEffectCache.addEffectItem(arg1.data as int, ItemEffectType.LightMask);
                loc2 = Math.floor((loc1 - 1) / this.pageSize);
                loc3 = (loc1 - 1) % this.pageSize;
                this._packModule.setTabBarSelect(0);
                this._packModule.setPageTabBarSelect(loc2);
                this._packModule.updateAllItem();
            }
            return;
        }

        /* internal  */get packWallet(): PackWallet
        {
            if (!this._packWallet) 
            {
                this._packWallet = new PackWallet();
                this._packWallet.addEventListener(WindowEvent.SHOW, this.onPackWalletShow);
                this._packWallet.addEventListener(WindowEvent.CLOSE, this.onPackWalletHide);
            }
            return this._packWallet;
        }

        /* internal  */onPackWalletShow(arg1: WindowEvent): void
        {
            this.updateWalletMoney(null);
            this.packWallet.showTips();
            NetDispatcher.addCmdListener(ServerCommand.MoneyUpdate, this.updateWalletMoney);
            return;
        }

        /* internal  */onPackWalletHide(arg1: WindowEvent): void
        {
            NetDispatcher.removeCmdListener(ServerCommand.MoneyUpdate, this.updateWalletMoney);
            return;
        }

        /* internal  */updateWalletMoney(arg1: Object): void
        {
            this.packWallet.updateMoney();
            return;
        }

        /* internal  */onFashionJewelGuide(arg1: DataEvent): void
        {
            if (!view.isHide) 
            {
                (view as IPackModule).checkFashionJewelAutoGuide();
            }
            return;
        }

        /* internal  */onBackPackShowOrhideWallet(arg1: DataEvent): void
        {
            if (this.packWallet.isHide) 
            {
                this.packWallet.show();
                (view as IPackModule).hideRightPart();
                this.packWallet.y = 0;
                this.packWallet.x = view.width + 5;
            }
            else 
            {
                this.packWallet.hide();
            }
            return;
        }

        /* internal  */Init(): void
        {
            this._packCache = cache.pack.backPackCache;
            this._packProxy = GameProxy.packProxy;
            return;
        }

        protected /* override */ initView(): IView
        {
            if (this._packModule == null) 
            {
                this._packModule = new PackModule();
                this._packModule.addEventListener(WindowEvent.SHOW, this.onPackShow);
                this._packModule.addEventListener(WindowEvent.CLOSE, this.onPackClose);
            }
            return this._packModule;
        }

        public /* override */ popup(): void
        {
            return;
        }

        /* internal  */packModuleClose(arg1: WindowEvent): void
        {
            Cache.instance.itemEffectCache.removeEffectItem();
            this._packModule.updateAllItem();
            return;
        }

        protected /* override */ initServer(): void
        {
            Dispatcher.addEventListener(EventName.Item_CoolDown, this.onPackItemCoolDownHandler);
            NetDispatcher.addCmdListener(ServerCommand.BackPackCapacityChange, this.updateCapacityChange);
            NetDispatcher.addCmdListener(ServerCommand.UpdateItemCdData, PackController.updateItemCdDataByFresh);
            NetDispatcher.addCmdListener(ServerCommand.BackpackDataChange, this.noticeShortCut);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.noticeShortCut);
            Dispatcher.addEventListener(EventName.Trade_StatusChange, this.onTradeStatusChange);
            Dispatcher.addEventListener(EventName.MarketSellWindowStateChange, this.onMarketSellStatusChange);
            Dispatcher.addEventListener(EventName.MarketSeekBuyWindowStateChange, this.onMarketBuyWindowStatusChange);
            Dispatcher.addEventListener(EventName.GuideItemStrengthenChange, this.onGuideItemStrengthenChange);
            Dispatcher.addEventListener(EventName.PetEggsChange, this.onPetEggsChange);
            Dispatcher.addEventListener(EventName.Mail_StatusChange, this.onMainStatusChange);
            Dispatcher.addEventListener(EventName.Stall_StatusChange, this.onStallStatusChange);
            Dispatcher.addEventListener(EventName.GuildWarehouseOpen, this.onGuildWarehouseOpen);
            Dispatcher.addEventListener(EventName.BackPack_Destroy, this.destroy);
            Dispatcher.addEventListener(EventName.BackPack_DragInItem, this.dragInItem);
            Dispatcher.addEventListener(EventName.BackPack_DragInBack, this.dragInBack);
            Dispatcher.addEventListener(EventName.BackPack_Split, this.split);
            Dispatcher.addEventListener(EventName.BackPack_Tity, this.tidy);
            Dispatcher.addEventListener(EventName.BackPack_Use, this.onUseItemHandler);
            Dispatcher.addEventListener(EventName.BackPack_BulkUse, this.onBulkUseItemHandler);
            Dispatcher.addEventListener(EventName.BackPack_Equip, this.onUserEquipHandler);
            Dispatcher.addEventListener(EventName.BackPack_EquipFabao, this.onUserEquipFabaoHandler);
            Dispatcher.addEventListener(EventName.BackPack_IdentifyFabao, this.onIdentifyFabaoHandler);
            Dispatcher.addEventListener(EventName.BackPack_EquipMount, this.onUserEquipMountHandler);
            Dispatcher.addEventListener(EventName.Fast_USE_BackPackExtend, this.onFastUserExtendItemHandler);
            Dispatcher.addEventListener(EventName.Fast_Move_BackPackItem_ToWareHouse, this.fastMoveItemToWareHuse);
            Dispatcher.addEventListener(EventName.OpenBackPackExtendItem, this.openBackPackExtendItem);
            Dispatcher.addEventListener(EventName.BackPack_DragInExtendItem, this.dragInExtendItem);
            Dispatcher.addEventListener(EventName.FeedPet, this.useItemToFeedPet);
            Dispatcher.addEventListener(EventName.BackPackShowTabIndex, this.onBackPackShowTabIndex);
            Dispatcher.addEventListener(EventName.ButtomBtn_BackPack_Merge, this.onMerge);
            Dispatcher.addEventListener(EventName.BackPackShowOrhideWallet, this.onBackPackShowOrhideWallet);
            Dispatcher.addEventListener(EventName.WalletMoneyUpdate, this.onWalletMoneyUpdate);
            Dispatcher.addEventListener(EventName.PackVIPRightShow, this.onPackVIPRightShow);
            Dispatcher.addEventListener(EventName.JewelWindowShow, this.moveJewelToStonePack);
            Dispatcher.addEventListener(EventName.ItemUseReq, this.itemUseReq);
            Dispatcher.addEventListener(EventName.BackPackCodeItemPlayEffect, this.backPackCodeItemEffect);
            Dispatcher.addEventListener(EventName.ShowBackPackModule, this.showBackPackModule);
            Dispatcher.addEventListener(EventName.ShowGuideBackPackModule, this.showGuideBackPackModule);
            Dispatcher.addEventListener(EventName.Guide_MountCall, this.showGuideBackPackModule);
            Dispatcher.addEventListener(EventName.Guide_UseDrug, this.onGuideUseDrugHandler);
            Dispatcher.addEventListener(EventName.Guide_UsePackage, this.showGuideBackPackModule);
            Dispatcher.addEventListener(EventName.Guide_UsePetEgg, this.showGuideBackPackModule);
            Dispatcher.addEventListener(EventName.Guide_UseAnyItemByConfig, this.showGuideBackPackByConfigHandler);
            Dispatcher.addEventListener(EventName.EnterVIPHook, this.onEnterVipHook);
            Dispatcher.addEventListener(EventName.Scene_Update, this.onSceneUpdate);
            NetDispatcher.addCmdListener(ServerCommand.BackpackDataChange, this.judgeFullPack);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.judgeFullPack);
            NetDispatcher.addCmdListener(ServerCommand.BackPackFullCommand, this.tipsFullPack);
            NetDispatcher.addCmdListener(ServerCommand.LuckAwardsOpenInfo, this.onLuckAwardsInfoHandler);
            NetDispatcher.addCmdListener(ServerCommand.FlyBindGoldCommand, this.flyBindGold);
            Dispatcher.addEventListener(EventName.PlayerDressWardrobeGuild, this.onPlayerDressWardrobeGuildHandler);
            Dispatcher.addEventListener(EventName.FashionJewelGuideStep2, this.onFashionJewelGuide);
            return;
        }

        /* internal  */onPackShow(arg1: Object /* flash.events.Event */): void
        {
            this.updatePack();
            this.updateMoney();
            this.updateExtendItems();
            this.changeVIPState();
            this._packModule.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.mouse_over);
            this._packModule.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.mouse_out);
            this._packModule.addEventListener(WindowEvent.CLOSE, this.packModuleClose);
            NetDispatcher.addCmdListener(ServerCommand.BackpackDataChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.StonepackDataChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.StonepackItemsChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.MagicWeaponPackDataChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.MagicWeaponPackItemsChange, this.updatePack);
            NetDispatcher.addCmdListener(ServerCommand.MoneyUpdate, this.updateMoney);
            NetDispatcher.addCmdListener(ServerCommand.BackPackExtendItemsChange, this.updateExtendItems);
            NetDispatcher.addCmdListener(ServerCommand.BackPackExtendDataChange, this.updateExtendItems);
            NetDispatcher.addCmdListener(ServerCommand.VIPInfoUpdateCommand, this.changeVIPState);
            Dispatcher.dispatchEvent(new DataEvent(EventName.PackWindowShow));
            if (this._tips && this._tips.parent) 
            {
                GuideTipsManager.hideGuideTips();
            }
            if (SystemSetter.currentSetter.wardrobeGuidState == 1) 
            {
                (view as IPackModule).wardrobeGuide();
            }
            return;
        }

        /* internal  */onPackClose(arg1: Object /* flash.events.Event */): void
        {
            NetDispatcher.removeCmdListener(ServerCommand.BackpackDataChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.StonepackDataChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.MagicWeaponPackDataChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.StonepackItemsChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.MagicWeaponPackItemsChange, this.updatePack);
            NetDispatcher.removeCmdListener(ServerCommand.MoneyUpdate, this.updateMoney);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackExtendItemsChange, this.updateExtendItems);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackExtendDataChange, this.updateExtendItems);
            Dispatcher.dispatchEvent(new DataEvent(EventName.PackWindowClose));
            this._guideUid = "";
            if (cache.shop.operType == ShopOperType.SALE) 
            {
                cache.shop.operType = "";
            }
            return;
        }

        /* internal  */showBackPackModule(arg1: DataEvent): void
        {
            var loc3=0;
            var loc1=arg1.data as ItemData;
            view.show();
            var loc2=2;
            if (loc1.category == ECategory._ECategoryEquip) 
            {
                loc2 = 2;
            }
            if (loc1.category == ECategory._ECategoryProp) 
            {
                if (ItemsUtil.isFixGiftBag(loc1)) 
                {
                    loc2 = 0;
                }
                else 
                {
                    loc2 = 1;
                }
            }
            var loc6=loc3;
            switch (loc6) 
            {
                case 2:
                {
                    loc3 = Cache.instance.pack.backPackCache.getIndexInEquip(loc1.uid);
                    break;
                }
                case 1:
                {
                    loc3 = Cache.instance.pack.backPackCache.getIndexInProp(loc1.uid);
                    break;
                }
                case 0:
                {
                    loc3 = Cache.instance.pack.backPackCache.getIndexByUid(loc1.uid);
                    break;
                }
                default:
                {
                    break;
                }
            }
            var loc4=Math.floor((loc3 - 1) / this.pageSize);
            var loc5=loc3 % this.pageSize;
            this._packModule.setTabBarSelect(loc2);
            this._packModule.setPageTabBarSelect(loc4);
            this._packModule.updateAllItem();
            this._packModule.setPackItemPanelSelect((loc5 - 1));
            return;
        }

        /* internal  */showGuideBackPackModule(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            this.guideItemUse(loc1, arg1.type);
            return;
        }

        /* internal  */onWalletMoneyUpdate(arg1: DataEvent): void
        {
            var loc1=arg1.data.toString();
            this.packWallet.addTips(loc1);
            return;
        }

        /* internal  */showGuideBackPackByConfigHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemData"];
            var loc2=arg1.data["type"];
            var loc3=arg1.data["typeParams"];
            this.guideItemUse(loc1, loc2, loc3);
            return;
        }

        /* internal  */onEnterVipHook(arg1: DataEvent): void
        {
            var loc1=int(arg1.data);
            var loc2="VIPHookCopyCode" + loc1;
            var loc3=ConstConfig.instance.getValueByName(loc2);
            GameProxy.copy.enterVIPHook(loc3);
            return;
        }

        /* internal  */onSceneUpdate(arg1: DataEvent): void
        {
            if (this._packModule) 
            {
                (view as IPackModule).resetHangText();
            }
            return;
        }

        /* internal  */onGuideUseDrugHandler(arg1: DataEvent): void
        {
            var loc1=null;
            if (cache.guide.guideUseHong) 
            {
                if (!cache.guide.guideUseLan) 
                {
                    loc1 = cache.pack.backPackCache.getItemsByJudge(ItemsUtil.isButianwan);
                }
            }
            else 
            {
                loc1 = cache.pack.backPackCache.getItemsByJudge(ItemsUtil.isChangeshengdan);
            }
            Cache.instance.itemEffectCache.removeEffectItem();
            (view as IPackModule).updateAllItem();
            if (!cache.guide.guideUseLan || !cache.guide.guideUseHong) 
            {
                if (loc1 && loc1.length > 0) 
                {
                    this.guideItemUse(loc1[0], EventName.Guide_UseDrug);
                }
                else if (_view && !_view.isHide) 
                {
                    view.hide();
                }
            }
            else if (_view && !_view.isHide) 
            {
                view.hide();
            }
            return;
        }

        /* internal  */onPackVIPRightShow(arg1: DataEvent): void
        {
            if (this._packWallet && !this._packWallet.isHide) 
            {
                this.packWallet.hide();
            }
            return;
        }

        /* internal  */guideItemUse(arg1: ItemData, arg2: string, arg3: string=""): void
        {
            var loc4=0;
            view.show();
            var loc1=2;
            if (arg1.category == ECategory._ECategoryAmulet) 
            {
                loc1 = 0;
                loc4 = Cache.instance.pack.magicWeaponPackCache.getIndexInEquip(arg1.uid);
                this._packModule.selectBackPackIndex = 2;
            }
            else 
            {
                if (arg1.category != ECategory._ECategoryEquip) 
                {
                    if (arg1.category != ECategory._ECategoryProp) 
                    {
                        if (arg1.category == ECategory._ECategoryDrug) 
                        {
                            loc1 = 0;
                        }
                    }
                    else 
                    {
                        loc1 = 1;
                    }
                }
                else 
                {
                    loc1 = 2;
                }
                if (loc1 != 2) 
                {
                    if (loc1 != 1) 
                    {
                        if (loc1 == 0) 
                        {
                            loc4 = Cache.instance.pack.backPackCache.getIndexByUid(arg1.uid);
                        }
                    }
                    else 
                    {
                        loc4 = Cache.instance.pack.backPackCache.getIndexInProp(arg1.uid);
                    }
                }
                else 
                {
                    loc4 = Cache.instance.pack.backPackCache.getIndexInEquip(arg1.uid);
                }
            }
            var loc2=Math.floor((loc4 - 1) / this.pageSize);
            var loc3=(loc4 - 1) % this.pageSize;
            this._packModule.setTabBarSelect(loc1);
            this._packModule.setPageTabBarSelect(loc2);
            this._packModule.setPackItemPanelSelect(loc3);
            if (arg2 != EventName.Guide_MountCall) 
            {
                if (arg2 == EventName.ShowGuideBackPackModule && cache.role.entityInfo.level <= 25) 
                {
                    this._packModule.setGuidePackIndex(loc3);
                }
                else if (arg2 != EventName.Guide_UsePackage) 
                {
                    if (arg2 != EventName.Guide_UseDrug) 
                    {
                        if (arg2 != EventName.Guide_UsePetEgg) 
                        {
                            if (arg2 == AutoGuideType.BackPack) 
                            {
                                this._packModule.setGuidePackIndex(loc3, arg3);
                            }
                        }
                        else 
                        {
                            this._packModule.setGuidePackIndex(loc3, Language.getString(40004) + HTMLUtil.addColor(arg1.itemInfo.item.name, ColorConfig.instance.getItemColor(arg1.itemInfo.item.color).color));
                        }
                    }
                    else 
                    {
                        this._packModule.setGuidePackIndex(loc3, Language.getString(40003));
                    }
                }
                else 
                {
                    this._packModule.setGuidePackIndex(loc3, Language.getString(40002));
                }
            }
            else 
            {
                this._packModule.setGuidePackIndex(loc3, Language.getString(40000) + HTMLUtil.addColor(Language.getString(40001), "#ffec18"));
            }
            Cache.instance.itemEffectCache.addEffectItem(arg1.itemInfo.item.code, ItemEffectType.LightMask);
            this._packModule.updateAllItem();
            this._guideUid = arg1.uid;
            return;
        }

        /* internal  */mouse_over(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=Cache.instance.shop.operType;
            switch (loc1) 
            {
                case ShopOperType.SALE:
                {
                    CursorManager.showCursor(CursorManager.SELL);
                    break;
                }
                case ShopOperType.FIX:
                {
                    CursorManager.showCursor(CursorManager.FIX);
                    break;
                }
            }
            return;
        }

        /* internal  */mouse_out(arg1: Object /* flash.events.MouseEvent */): void
        {
            CursorManager.showCursor(CursorManager.NO_CURSOR);
            return;
        }

        /* internal  */updateExtendItems(arg1: Object=null): void
        {
            if (!_view) 
            {
                return;
            }
            (view as IPackModule).updateExtendAllItems();
            if (arg1) 
            {
                if (arg1["selectIndex"] == -1) 
                {
                    this._packModule.updataPackExtendItemPanelSelectItem(-1);
                }
                else 
                {
                    this._packModule.updataPackExtendItemPanelSelectItem((arg1["selectIndex"] - 1));
                }
            }
            return;
        }

        /* internal  */updatePack(arg1: Object=null): void
        {
            (view as IPackModule).updateAllItem();
            if (arg1) 
            {
                if (arg1["selectIndex"] == -1) 
                {
                    this._packModule.updataPackItemPanelSelectItem(-1);
                }
                else 
                {
                    this._packModule.updataPackItemPanelSelectItem((arg1["selectIndex"] - 1));
                }
            }
            return;
        }

        /* internal  */moveJewelToStonePack(arg1: DataEvent): void
        {
            if (GameController.trade.isInTrade()) 
            {
                return;
            }
            GameProxy.packProxy.moveJewelToStonePack();
            return;
        }

        /* internal  */judgeFullPack(arg1: Object=null): void
        {
            if (cache.pack.backPackCache.getSpareCapacity() <= 0) 
            {
                if (!this.isFull) 
                {
                    this.tipsFullPack();
                }
                this.isFull = true;
            }
            else 
            {
                this.isFull = false;
            }
            return;
        }

        /* internal  */tipsFullPack(arg1: Object=null): void
        {
            var loc1=null;
            if (!PulseSharedObject.isTodayNotTips("packFull")) 
            {
                loc1 = new MsgTipInfo();
                loc1.type = 1;
                loc1.displayObject = new PackFullTips();
                loc1.isAutoHide = true;
                loc1.notTipEvent = "packFull";
                Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipDateChange, loc1));
            }
            return;
        }

        /* internal  */flyBindGold(arg1: Object=null): void
        {
            var loc2=null;
            var loc1=new Object /* flash.geom.Point */(Global.stage.mouseX, Global.stage.mouseY);
            if ((view as IPackModule).isHide) 
            {
                loc2 = (GameController.gameui.view as GameUI).getNavbarIconGlobalPoint(ModuleType.Pack);
                loc2.x = loc2.x + 10;
                loc2.y = loc2.y + 10;
                FlyToNavbarTool.flyToAnyPoint(GlobalClass.getBitmapData(ImagesConst.Yuanbao_bind), loc1, loc2, this.flyCallBack);
            }
            else 
            {
                FlyToNavbarTool.flyToAnyPoint(GlobalClass.getBitmapData(ImagesConst.Yuanbao_bind), loc1, (view as IPackModule).getBindGoldPosition(), this.flyCallBack);
            }
            return;
        }

        public static updateItemCdDataByFresh(arg1): void
        {
            ItemCoolDownUtil.instance.updateItemCdByFresh(arg1 as SDrugCanUseDtMsg);
            return;
        }

        /* internal  */onPlayerDressWardrobeGuildHandler(arg1: DataEvent): void
        {
            var loc1=null;
            if (this._packModule && !this._packModule.isHide) 
            {
                (view as IPackModule).wardrobeGuide();
            }
            else 
            {
                this._tips = GuideTipsManager.getGuideTips(GuideTipsManager.Dir_BR, Language.getString(90334), null, null, -1, -1, true, this.onClickTips);
                loc1 = (GameController.gameui.view as GameUI).getNavbarIconGlobalPoint(ModuleType.Pack);
                this._tips.x = loc1.x + 20;
                this._tips.y = loc1.y;
                LayerManager.topLayer.addChild(this._tips);
            }
            return;
        }

        /* internal  */onClickTips(): void
        {
            GuideTipsManager.hideGuideTips();
            view.show();
            if (!view.isHide && SystemSetter.currentSetter.wardrobeGuidState == 1) 
            {
                (view as IPackModule).wardrobeGuide();
            }
            return;
        }

        /* internal  */flyCallBack(arg1: Object /* flash.display.Bitmap */): void
        {
            if (arg1 && arg1.parent) 
            {
                arg1.parent.removeChild(arg1);
            }
            return;
        }

        /* internal  */noticeShortCut(arg1: Object=null): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShortCutsItemChange));
            return;
        }

        /* internal  */changeVIPState(arg1: Object=null): void
        {
            (view as IPackModule).showOrHideVIPBtn(cache.vip.isVIP, cache.vip.isHaveGetBindGold() || cache.vip.isHaveGetChangeShape());
            return;
        }

        /* internal  */updateMoney(arg1: Object=null): void
        {
            (view as IPackModule).updateMoney();
            return;
        }

        /* internal  */dragInItem(arg1: DataEvent): void
        {
            var e: DataEvent;
            var fromIndex: int;
            var toIndex: int;
            var uidDrag: string;
            var fromItemData: ItemData;
            var toItemData: ItemData;
            var itemData: ItemData;
            var len: int;
            var toItemIsExtend: Boolean;
            var dragDropData: DragDropData;
            var onCheckOp: Function;
            var packCache: PackPosTypeCache;

            var loc1;
            fromIndex = 0;
            toIndex = 0;
            uidDrag = null;
            fromItemData = null;
            toItemData = null;
            itemData = null;
            len = 0;
            toItemIsExtend = false;
            dragDropData = null;
            onCheckOp = null;
            packCache = null;
            e = arg1;
            onCheckOp = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    _packProxy.merge(dragDropData.fromPosType, dragDropData.toItemData.uid, dragDropData.fromItemData.uid);
                }
                return;
            }
            this._page = this._packModule.pageTabBarSelect;
            dragDropData = e.data as DragDropData;
            var loc2=dragDropData.fromPosType;
            switch (loc2) 
            {
                case EPlayerItemPosType._EPlayerItemPosTypeBag: case EPlayerItemPosType._EPlayerItemPosTypeStoneBag: case EPlayerItemPosType._EPlayerItemPosTypeAmuletBag:
                {
                    if (!ItemsUtil.isMaxOverlay(dragDropData.fromItemData) && !ItemsUtil.isMaxOverlay(dragDropData.toItemData)) 
                    {
                        if (ItemsUtil.isSameItemData(dragDropData.fromItemData, dragDropData.toItemData)) 
                        {
                            this._packProxy.merge(dragDropData.fromPosType, dragDropData.toItemData.uid, dragDropData.fromItemData.uid);
                            break;
                        }
                        if (ItemsUtil.isBindSameItemData(dragDropData.fromItemData, dragDropData.toItemData)) 
                        {
                            Alert.show(Language.getString(40005), null, Alert.OK | Alert.CANCEL, null, onCheckOp);
                            break;
                        }
                    }
                    packCache = Cache.instance.pack.getPackChacheByPosType(dragDropData.fromPosType);
                    fromIndex = packCache.getIndexByUid(dragDropData.uid);
                    toIndex = this.pageSize * this._page + dragDropData.toIndex;
                    dragDropData.fromIndex = fromIndex;
                    dragDropData.toIndex = toIndex;
                    if (toIndex <= packCache.sbag.capacity) 
                    {
                        this._packProxy.moveInBag(dragDropData);
                    }
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWarehouse:
                {
                    fromIndex = Cache.instance.pack.wareHousePackCache.getIndexByUid(dragDropData.uid);
                    toIndex = this.pageSize * this._page + dragDropData.toIndex;
                    dragDropData.fromIndex = fromIndex;
                    dragDropData.toIndex = toIndex;
                    if (toIndex <= Cache.instance.pack.backPackCache.sbag.capacity) 
                    {
                        this._packProxy.move(dragDropData);
                    }
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRole:
                {
                    GameController.player.unDress(dragDropData.uid);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar:
                {
                    fromIndex = Cache.instance.pack.backPackExtendPackCache.getIndexByUid(dragDropData.uid);
                    toIndex = this.pageSize * this._page + dragDropData.toIndex;
                    dragDropData.fromIndex = fromIndex;
                    dragDropData.toIndex = toIndex;
                    this.moveExtendItem(dragDropData, this._packProxy);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar:
                {
                    fromIndex = Cache.instance.pack.wareHouseExtendPackCache.getIndexByUid(dragDropData.uid);
                    toIndex = this.pageSize * this._page + dragDropData.toIndex;
                    dragDropData.fromIndex = fromIndex;
                    dragDropData.toIndex = toIndex;
                    this.moveExtendItem(dragDropData, this._packProxy);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeGuildWarehouse:
                {
                    fromItemData = dragDropData.fromItemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseTake, fromItemData.data));
                    break;
                }
            }
            return;
        }

        /* internal  */dragInBack(arg1: DataEvent): void
        {
            var loc1=arg1.data as DragDropData;
            var loc2=loc1.fromPosType;
            switch (loc2) 
            {
                case 0:
                {
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRole:
                {
                    GameController.player.unDress(loc1.uid);
                    break;
                }
            }
            return;
        }

        /* internal  */split(arg1: DataEvent): void
        {
            if (arg1.data) 
            {
                this._packProxy.split(arg1.data["uid"] as string, arg1.data["amount"] as int);
            }
            return;
        }

        /* internal  */tidy(arg1: DataEvent): void
        {
            var loc1=(view as IPackModule).selectBackPackIndex;
            if (GameController.trade.isInTrade()) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40106));
                return;
            }
            if (loc1 != 0) 
            {
                if (loc1 != 1) 
                {
                    if (loc1 == 2) 
                    {
                        this._packProxy.tidyNow(EPlayerItemPosType._EPlayerItemPosTypeAmuletBag);
                    }
                }
                else 
                {
                    this._packProxy.tidyNow(EPlayerItemPosType._EPlayerItemPosTypeStoneBag);
                }
            }
            else 
            {
                this._packProxy.tidy(true);
            }
            return;
        }

        /* internal  */onBulkUseItemHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemData"];
            var loc2=arg1.data["amount"];
            if (ItemsUtil.isPetDrug(loc1)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetFeedInPack, {"itemData": loc1, "amount": loc2}));
            }
            else if (ItemsUtil.isInvitation(loc1)) 
            {
                if (cache.marry.isCanInvitation()) 
                {
                    GameProxy.marry.useInviteCard(loc1.uid, loc2);
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(43643));
                }
            }
            else if (ItemsUtil.isMountExpDrug(loc1)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountExpDrugUse, {"itemData": loc1, "amount": loc2}));
            }
            else if (ItemsUtil.isChangeHeadIcon(loc1)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OpenChangeHeadIconWindow, loc1.uid));
            }
            else if (ItemsUtil.isHappyBag(loc1)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PackBulkUsePropHappyBag, {"data": loc1, "amount": loc2}));
            }
            else 
            {
                GameProxy.packProxy.useItem(loc1.uid, loc2);
            }
            return;
        }

        /* internal  */onUseItemHandler(arg1: DataEvent): void
        {
            this.useItem(arg1.data as ItemData);
            return;
        }

        /* internal  */onLuckAwardsInfoHandler(arg1: SActiveToClient): void
        {
            this._isActiveOpen = arg1.status;
            return;
        }

        public useItem(arg1: ItemData): void
        {
            var itemData: ItemData;
            var uid: string;
            var name: string;
            var dic: Map<any, any> /* flash.utils.Dictionary */;
            var sexLimit: int;
            var titleCode: int;
            var titleInfo: TitleInfo;
            var des: string;
            var isHaveThisTitle: Boolean;
            var titleName: string;
            var isCanUse: Boolean;
            var onConfirm: Function;
            var titleDay: int;
            var specialRewardItemInfo: SpecialRewardItemInfo;
            var endDate: Date;
            var selectEntity: IEntity;
            var toUserPlayer: UserPlayer;
            var cd: CDBackPackItem;
            var buffInfo: BuffInfo;

            var loc1;
            uid = null;
            dic = null;
            sexLimit = 0;
            titleCode = 0;
            titleInfo = null;
            des = null;
            isHaveThisTitle = false;
            titleName = null;
            isCanUse = false;
            titleDay = 0;
            specialRewardItemInfo = null;
            endDate = null;
            selectEntity = null;
            toUserPlayer = null;
            cd = null;
            buffInfo = null;
            itemData = arg1;
            uid = itemData.uid;
            name = itemData.itemInfo.item.name;
            if (this._guideUid && this._guideUid == uid) 
            {
                this._guideUid = "";
                this._packModule.cacelPackIndexGuide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideItemUsed, itemData));
            }
            if (itemData.itemCode == 14168001) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Lv88TeamUseProp));
                return;
            }
            if (!this._isActiveOpen && (itemData.itemCode == 14186000 || itemData.itemCode == 14186001)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(100011));
                return;
            }
            if (!ItemsUtil.isPetUse(itemData) && itemData.itemInfo.item.level > cache.role.entityInfo.level) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40006) + itemData.itemInfo.item.level + Language.getString(40007));
            }
            else if (ItemsUtil.isPackage(itemData)) 
            {
                this.fastUseExtendItem(itemData);
            }
            else if (ItemsUtil.isArenaGiftBag(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PackOpenArenaGiftBag, itemData));
            }
            else if (ItemsUtil.isRandItemPetSkill(itemData) || ItemsUtil.isRandItemJewel(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.RandomPropOpen, {"itemData": itemData, "amount": itemData.itemAmount}));
            }
            else if (ItemsUtil.isSkillBook(itemData)) 
            {
                GameProxy.skillProxy.learnByBook(itemData);
            }
            else if (ItemsUtil.isPetSkillForget(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 0));
            }
            else if (ItemsUtil.isPetModelChange(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 5));
            }
            else if (ItemsUtil.isAddPetBlessItem(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 0));
            }
            else if (ItemsUtil.isPetSkillDig(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 4));
            }
            else if (ItemsUtil.isPetLifeSpan(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetLifespanWindowOpen));
            }
            else if (ItemsUtil.isPropOfflineAddExperience(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OfflineExpPropUse));
            }
            else if (ItemsUtil.isPropColorStone(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.UsePropColorStone, itemData));
            }
            else if (ItemsUtil.isPropTransportFlushToken(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.UseTransportFlushToken, itemData));
            }
            else if (ItemsUtil.isTaskSilverNote(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.UseTaskSilverNote, itemData));
            }
            else if (ItemsUtil.isTrumpet(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowSpeaker));
            }
            else if (ItemsUtil.isHuntMap(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ItemUse_HuntMap, itemData));
            }
            else if (ItemsUtil.isHuntShovel(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ItemUse_HuntShovel, itemData));
            }
            else if (ItemsUtil.isPetEquipUpgradeStarProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdatePetEquipUpgradeStar));
            }
            else if (ItemsUtil.isPetEquipRecastProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdatePetEquipRecast));
            }
            else if (ItemsUtil.isEquipStrengthenLuckRune(itemData) || ItemsUtil.isEquipStrengthenMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_Strengthen, itemData));
            }
            else if (ItemsUtil.isEquipRefineLuckRune(itemData) || ItemsUtil.isEquipRefineMaterial(itemData) || ItemsUtil.isEquipRefreshLock(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_Recast, itemData));
            }
            else if (ItemsUtil.isEquipAdvanceMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_EquipAdvance, itemData));
            }
            else if (ItemsUtil.isEquipAdvanceColorMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_EquipAdvanceColor, itemData));
            }
            else if (ItemsUtil.isEquipPrefixUpgradeMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_EquipPrefixUpgrade, itemData));
            }
            else if (ItemsUtil.isEquipMakeHoleRune(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_MakeHole, itemData));
            }
            else if (ItemsUtil.isEquipEmbedRune(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_EmbedJewel, itemData));
            }
            else if (ItemsUtil.isEquipRemoveRune(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_RemoveJewel, itemData));
            }
            else if (ItemsUtil.isJewelComposeRune(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast_ComposeJewel, itemData));
            }
            else if (ItemsUtil.isSmeltMaterial(itemData) && !(SmeltConfig.instance.getSmeltPlanByMaterial(itemData.itemCode) == null)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.SmeltOpenSmeltByMaterialData, itemData));
            }
            else if (ItemsUtil.isJewelAdvance(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdateJewelAddance));
            }
            else if (ItemsUtil.isPetEquipPrefix(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Equipment_DoCast, EItemUpdateOper._EItemUpdatePetEquipUpgradePrefix));
            }
            else if (ItemsUtil.isPetDrug(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetFeedInPack, {"itemData": itemData, "amount": 1}));
            }
            else if (ItemsUtil.isChangeShape(itemData)) 
            {
                this.confirmChangeShape(itemData);
            }
            else if (ItemsUtil.isFlower(itemData) || ItemsUtil.isBlueFlower(itemData) || ItemsUtil.isBlackFlower(itemData) || ItemsUtil.isNewFlower(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.FlowerUseInPack, itemData));
            }
            else if (ItemsUtil.isChristmasCard(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChristmasCardUseInPack, itemData));
            }
            else if (ItemsUtil.isPetSkillRand(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillOpenRefreshWindow, itemData));
            }
            else if (ItemsUtil.isKillEvilToken(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.KillEvilTaskUsePropFromPack, itemData));
            }
            else if (ItemsUtil.isPropAddResource(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.OpenGuildContriWindow, itemData));
            }
            else if (ItemsUtil.isPetGrowUpMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 2));
            }
            else if (ItemsUtil.isPetEquipUpgradeProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetEquipOpenByIndex, 6));
            }
            else if (ItemsUtil.isGodSoulMaterial(itemData)) 
            {
                GameController.godSoul.view.show();
            }
            else if (ItemsUtil.isPetTalentAdvanceMaterial(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 1));
            }
            else if (ItemsUtil.isPetXisuiItem(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetXisuiOpen));
            }
            else if (ItemsUtil.isGuildCreat(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.OpenCreateGuildWindow));
            }
            else if (ItemsUtil.isWuXingSpiritUpgrade(itemData)) 
            {
                GameController.wuxing.showQuailtyPanel();
            }
            else if (ItemsUtil.isWuXingAttributeRefresh(itemData)) 
            {
                GameController.wuxing.showRefreshPanel();
            }
            else if (ItemsUtil.isWuXingUpSpirit(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.WuXingModuleOpenReqByIndex, 3));
            }
            else if (ItemsUtil.isMountAdvance(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountButtonSkipToTabBar, 2));
            }
            else if (ItemsUtil.isJewelPureChip(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.JewelModuleOpenByIndex, 3));
            }
            else if (ItemsUtil.isMountEquipUpgradeProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountButtonSkipToTabBar, 7));
            }
            else if (ItemsUtil.isMountStarsCulture(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountButtonSkipToTabBar, 6));
            }
            else if (ItemsUtil.isMountRefreshGrow(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountButtonSkipToTabBar, 3));
            }
            else if (ItemsUtil.isChangeHeadIcon(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OpenChangeHeadIconWindow, itemData.uid));
            }
            else if (ItemsUtil.isCopyDrawRewardItem(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CopyCopyDrawRewards, itemData));
            }
            else if (ItemsUtil.isHappyBag(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PackUsePropHappyBag, itemData));
            }
            else if (ItemsUtil.isLotteryKey(itemData) || ItemsUtil.isLotteryHeavenKey(itemData) || ItemsUtil.isLotteryKunlunKey(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureModuleOpen, itemData));
            }
            else if (ItemsUtil.isRootProp(itemData) || ItemsUtil.isRootProtect(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerRootUpdateOpen, itemData));
            }
            else if (ItemsUtil.isInvitation(itemData)) 
            {
                if (cache.marry.isCanInvitation()) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MarryPackUseInvitation, itemData));
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(43643));
                }
            }
            else if (ItemsUtil.isPlayerRenameProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerRenamePropUsed, {"itemData": itemData, "type":"player"}));
            }
            else if (ItemsUtil.isGuildRenameProp(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerRenamePropUsed, {"itemData": itemData, "type":"guild"}));
            }
            else if (ItemsUtil.isGuildImpeachLeader(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildImpeachWindowOpen));
            }
            else if (ItemsUtil.isGuildAnimalFood(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OpenGuildWindow, 6));
            }
            else if (ItemsUtil.isRootBreakThrough(itemData)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AcupointRootBreakOpen));
            }
            else if (itemData.itemCode != GameConst.PetEggRandomGiftBag) 
            {
                if (ItemsUtil.is5FBChip(itemData)) 
                {
                    GameProxy.packProxy.use5FBChip(itemData.uid);
                }
                else if (ItemsUtil.isRuneGrowth(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RuneOpenFeedWindow));
                }
                else if (ItemsUtil.isPetMingJuProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetMingJuWindowOpen));
                }
                else if (ItemsUtil.isluckAwardsDrawPlateProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.LuckAwardsOpen, itemData));
                }
                else if (ItemsUtil.isIllustrate(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.IllustrateModuleOpen, itemData));
                }
                else if (MagicWeaponUtil.isMagicWeaponOpenInPackItem(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponShowView, itemData));
                }
                else if (ItemsUtil.isPetBloodVesselItem(itemData)) 
                {
                    if (PetUtil.activeItemCodes.indexOf(itemData.itemCode) > -1) 
                    {
                        PetUtil.curUseBloodItemCode = itemData.itemCode;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 8));
                }
                else if (ItemsUtil.isSpecialPetSkillBook(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 9));
                }
                else if (ItemsUtil.isActivceSnowball(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.SnowballItemUse, itemData));
                }
                else if (ItemsUtil.isCountryDynamicProp(itemData) || ItemsUtil.isCountryStaticProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.CountryMoneyPropPackUse, itemData));
                }
                else if (ItemsUtil.isTreasureBoxProp(itemData) || ItemsUtil.isTreasureBoxKeyProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureBoxPropUsedOpen, itemData));
                }
                else if (ItemsUtil.isHitEgg(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.HitEggOpenWindow));
                }
                else if (ItemsUtil.isMountLevelBack(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MountLvBackUseDrug, itemData));
                }
                else if (ItemsUtil.isFahunUpgradeItem(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FahunShowTab, {"operIndex": 0, "itemIndex":-1}));
                }
                else if (ItemsUtil.isFahunBreakItem(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FahunShowTab, {"operIndex": 1, "itemIndex":-1}));
                }
                else if (ItemsUtil.isFlyWingProp(itemData)) 
                {
                    dic = new Map<any, any> /* flash.utils.Dictionary */();
                    dic[itemData.uid] = 1;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FashionFlyWingGoUpgradeLv, dic));
                }
                else if (ItemsUtil.isFlyGrowProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FashionBoxModuleShowToTab, 3));
                }
                else if (ItemsUtil.isRedPack(itemData)) 
                {
                    if (cache.active.newRedPackIsOpen) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.UseNewYearRedPack));
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(100011));
                    }
                }
                else if (ItemsUtil.isTitleProp(itemData)) 
                {
                    onConfirm = (arg1: int): void
                    {
                        if (isCanUse && arg1 == Alert.OK) 
                        {
                            GameProxy.packProxy.useItem(uid);
                        }
                        return;
                    }
                    sexLimit = itemData.itemInfo.item.effectEx;
                    if (!(sexLimit == 2) && !(sexLimit == cache.role.entityInfo.sex)) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(40094));
                        return;
                    }
                    titleCode = itemData.effect;
                    titleInfo = TitleConfig.instance.getInfoByCode(titleCode);
                    des = "";
                    isHaveThisTitle = cache.title.isOwnTitle(titleCode);
                    titleName = TitleConfig.instance.getTitleName(titleInfo);
                    isCanUse = true;
                    var loc2=titleInfo.type;
                    switch (loc2) 
                    {
                        case 2:
                        {
                            titleDay = Math.ceil(titleInfo.existTime / (24 * 60));
                            specialRewardItemInfo = SpecialRewardItemConfig.instance.getInfoByCode(itemData.itemCode);
                            if (specialRewardItemInfo) 
                            {
                                endDate = specialRewardItemInfo.effectDay;
                                des = des + DateParser.parse(endDate, Language.getStringByParam(40097, titleName));
                            }
                            else 
                            {
                                des = des + Language.getStringByParam(40090, titleName, titleDay);
                            }
                            if (isHaveThisTitle) 
                            {
                                des = des + Language.getString(40091);
                            }
                            break;
                        }
                        case 1:
                        {
                            if (isHaveThisTitle) 
                            {
                                des = des + Language.getString(40093);
                                isCanUse = false;
                            }
                            else 
                            {
                                des = des + Language.getStringByParam(40092, titleName);
                            }
                            break;
                        }
                    }
                    Alert.show(des, null, isCanUse ? Alert.OK | Alert.CANCEL : OK, null, onConfirm);
                }
                else if (ItemsUtil.isGuildCallTogetherProp(itemData)) 
                {
                    if (cache.guild.isCanUseCallTogether()) 
                    {
                        Alert.show(Language.getString(60752), Language.getString(69900), Alert.OK | Alert.CANCEL, null, (arg1: int): void
                        {
                            if (arg1 == Alert.OK) 
                            {
                                GameProxy.packProxy.useItem(uid);
                            }
                            return;
                        })
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(60757));
                    }
                }
                else if (ItemsUtil.isMakeFunProp(itemData)) 
                {
                    selectEntity = GameController.scene.selectEntity;
                    if (selectEntity && selectEntity is UserPlayer) 
                    {
                        toUserPlayer = selectEntity as UserPlayer;
                        if (toUserPlayer.isTurned) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40008));
                        }
                        else if (toUserPlayer.isDoubleRest || toUserPlayer.isRest) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40009));
                        }
                        else if (toUserPlayer.entityInfo.isStall) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40010));
                        }
                        else if (toUserPlayer.isDead) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40011));
                        }
                        else if (ThingUtil.entityUtil.getEntity(toUserPlayer.entityInfo.entityInfo.entityId)) 
                        {
                            if (EntityUtil.isSameServerByRole(toUserPlayer.entityInfo.entityInfo.entityId)) 
                            {
                                GameProxy.packProxy.useItem(uid, 1, [(selectEntity as UserPlayer).entityInfo.entityInfo.entityId.id.toString()]);
                            }
                            else 
                            {
                                MsgManager.showRollTipsMsg(Language.getString(90320));
                            }
                        }
                        else 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40012));
                        }
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(40013));
                    }
                }
                else if (ItemsUtil.isFish(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.StartRoastFish, itemData));
                }
                else if (ItemsUtil.isNotCanUse(itemData)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(40015));
                }
                else if (ItemsUtil.isMountExpDrug(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MountExpDrugUse, {"itemData": itemData, "amount": 1}));
                }
                else if (ItemsUtil.isLuckyBag(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.LuckyBagOpentouse, itemData.uid));
                }
                else if (ItemsUtil.isFightSpirit(itemData)) 
                {
                    if (cache.role.fightSpiritOpenFlag != 1) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FightSpiritGogetMisson));
                    }
                    else 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FightSpiritShowModule));
                    }
                }
                else if (ItemsUtil.isPlantFlowerProp(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PlantFlower_PlantFlower, itemData));
                }
                else if (ItemsUtil.isGuessCouplet(itemData)) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChunlianOpen, itemData));
                }
                else if (ItemsUtil.isCanUseInBag(itemData)) 
                {
                    if (cache.guide.guideUseDrug) 
                    {
                        if (ItemsUtil.isChangeshengdan(itemData)) 
                        {
                            cache.guide.guideUseHong = true;
                            this.onGuideUseDrugHandler(null);
                        }
                        else if (ItemsUtil.isButianwan(itemData)) 
                        {
                            cache.guide.guideUseLan = true;
                            this.onGuideUseDrugHandler(null);
                        }
                    }
                    cd = cache.timeCdCache.getCdTime(itemData);
                    if (cd) 
                    {
                        if (cd.isRequestCd || cd.isCoolDown) 
                        {
                            return;
                        }
                    }
                    else 
                    {
                        cd = cache.timeCdCache.addCDTime(itemData);
                    }
                    if (uid == null) 
                    {
                        uid = cache.pack.backPackCache.getFirstItemUid(name);
                    }
                    if (uid) 
                    {
                        cd.startItemCd();
                        if (ItemsUtil.isAttrDrug(itemData)) 
                        {
                            buffInfo = cache.buff.getCanNotUseBuffInfo(itemData);
                            if (buffInfo) 
                            {
                                this.showItemTips(buffInfo, itemData);
                                return;
                            }
                            SoundManager.instance.soundPlay(SoundTypeConst.UseBuffDrugs);
                        }
                        else if (ItemsUtil.isInstantDrug(itemData)) 
                        {
                            SoundManager.instance.soundPlay(SoundTypeConst.UseDrugs);
                        }
                        if (ItemsUtil.isNoviceGrowthGift(itemData)) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.NoviceGiftUseInBag, itemData));
                        }
                        GameProxy.packProxy.useItem(uid);
                    }
                }
                else if (ItemsUtil.isOpenFunc(itemData)) 
                {
                    if (ItemsUtil.isTaskLoopBook(itemData)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.UseTaskFlushLoopBook, itemData));
                    }
                    else if (ItemsUtil.isQuickComTaskItem(itemData)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.TaskQuickComByItem, itemData));
                    }
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetEggRandOpen, itemData.uid));
            }
            return;
        }

        /* internal  */confirmChangeShape(arg1: ItemData): void
        {
            var itemData: ItemData;
            var color1: string;
            var isNeedAlert: Boolean;
            var closeHandler: Function;

            var loc1;
            closeHandler = null;
            itemData = arg1;
            closeHandler = (arg1: int, arg2: Boolean): void
            {
                if (arg1 == Alert.OK) 
                {
                    GameProxy.packProxy.useItem(itemData.uid);
                }
                if (arg2) 
                {
                    PulseSharedObject.save("UseChangeShapeDrug", true);
                }
                Alert.resetToDefault();
                return;
            }
            if (GameController.stall.isInStall) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40016));
                return;
            }
            if (RolePlayer.instance.isMakeFunTargetStatus) 
            {
                MsgManager.showRollTipsMsg(Language.getString(40017));
                return;
            }
            if (GameMapUtil.curMapState.isCrossBeach) 
            {
                MsgManager.showRollTipsMsg(Language.getString(69808));
                return;
            }
            if (GameMapUtil.curMapState.isCrossDefenceCopy) 
            {
                MsgManager.showRollTipsMsg(Language.getString(27630));
                return;
            }
            if (GameMapUtil.curMapState.isGodSpeedwayCopy) 
            {
                MsgManager.showRollTipsMsg(Language.getString(27631));
                return;
            }
            color1 = ColorConfig.instance.getItemColor(itemData.color).color;
            isNeedAlert = !PulseSharedObject.isTodayNotTips("UseChangeShapeDrug");
            if (RolePlayer.instance.isTurned && isNeedAlert) 
            {
                Alert.alertWinRenderer = CheckBoxWin;
                Alert.show(Language.getString(40018) + HTMLUtil.addColor(Language.getString(40019) + itemData.itemInfo.item.name + Language.getString(40020), color1) + Language.getString(40021), null, Alert.OK | Alert.CANCEL, null, closeHandler);
            }
            else 
            {
                GameProxy.packProxy.useItem(itemData.uid);
            }
            return;
        }

        /* internal  */showItemTips(arg1: BuffInfo, arg2: ItemData): void
        {
            var buffInfo: BuffInfo;
            var itemData: ItemData;
            var color1: string;
            var color2: string;
            var closeHandler: Function;

            var loc1;
            closeHandler = null;
            buffInfo = arg1;
            itemData = arg2;
            closeHandler = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    GameProxy.packProxy.useItem(itemData.uid);
                    SoundManager.instance.soundPlay(SoundTypeConst.UseBuffDrugs);
                }
                return;
            }
            color1 = ColorConfig.instance.getItemColor(itemData.color).color;
            color2 = GlobalStyle.color5;
            Alert.show(Language.getString(40022) + HTMLUtil.addColor("[" + itemData.itemInfo.item.name + "]", color1) + Language.getString(40023) + HTMLUtil.addColor("[" + buffInfo.tstate.name + "]", color2) + Language.getString(40024), null, Alert.OK | Alert.CANCEL, null, closeHandler);
            return;
        }

        /* internal  */useItemToFeedPet(arg1: DataEvent): void
        {
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc1=arg1.data["itemData"] as ItemData;
            if (loc1) 
            {
                loc2 = arg1.data["amount"] as int;
                loc3 = arg1.data["petUid"] as string;
                if (loc1.isCanCD()) 
                {
                    if (loc4 = cache.timeCdCache.getCdTime(loc1)) 
                    {
                        if (loc4.isRequestCd || loc4.isCoolDown) 
                        {
                            return;
                        }
                    }
                    else 
                    {
                        loc4 = cache.timeCdCache.addCDTime(loc1);
                    }
                    if (loc4) 
                    {
                        loc4.startItemCd();
                        GameProxy.packProxy.useItem(loc1.uid, loc2, [loc3]);
                    }
                }
                else 
                {
                    GameProxy.packProxy.useItem(loc1.uid, loc2, [loc3]);
                }
            }
            return;
        }

        /* internal  */onMerge(arg1: DataEvent): void
        {
            var loc1=EPlayerItemPosType._EPlayerItemPosTypeBag;
            var loc2=(view as IPackModule).selectBackPackIndex;
            if (loc2 != 1) 
            {
                if (loc2 == 2) 
                {
                    loc1 = EPlayerItemPosType._EPlayerItemPosTypeAmuletBag;
                }
            }
            else 
            {
                loc1 = EPlayerItemPosType._EPlayerItemPosTypeStoneBag;
            }
            GameProxy.packProxy.fastMerge(loc1);
            return;
        }

        /* internal  */onBackPackShowTabIndex(arg1: DataEvent): void
        {
            (view as IPackModule).show();
            var loc1=0;
            if (arg1.data) 
            {
                loc1 = int(arg1.data);
            }
            (view as IPackModule).setPageTabBarSelect(0);
            (view as IPackModule).setTabBarSelect(loc1);
            (view as IPackModule).updateAllItem();
            return;
        }

        public useEquipItem(arg1: ItemData): void
        {
            if (arg1) 
            {
                if (arg1.itemInfo.item.level > cache.role.entityInfo.level) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(40025) + arg1.itemInfo.item.level + Language.getString(40026));
                }
                else 
                {
                    EquipmentUtil.suitAttrUnlockAlert(arg1, true, this.dressReq, arg1);
                }
            }
            return;
        }

        /* internal  */dressReq(arg1: Object): void
        {
            var loc1=arg1 as ItemData;
            GameController.player.dress(loc1.posType, loc1.uid);
            return;
        }

        public equipMount(arg1: ItemData): void
        {
            var loc1=0;
            var loc2=0;
            if (arg1) 
            {
                if (arg1.itemInfo.item.level > cache.role.entityInfo.level) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(40025) + arg1.itemInfo.item.level + Language.getString(40027));
                }
                else 
                {
                    if (arg1.itemInfo.item.category == ECategory._ECategoryMount) 
                    {
                        loc1 = MountConfig.instance.getSexLimit(arg1.itemExInfo.model_id);
                        loc2 = Cache.instance.role.entityInfo.sex;
                        if (loc2 == ESex._ESexMan && loc1 == ESex._ESexWoman || loc2 == ESex._ESexWoman && loc1 == ESex._ESexMan) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(70176));
                            return;
                        }
                    }
                    GameController.player.dress(arg1.posType, arg1.uid);
                }
            }
            return;
        }

        /* internal  */onUserEquipHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (this._guideUid && this._guideUid == loc1.uid) 
            {
                this._guideUid = "";
                this._packModule.cacelPackIndexGuide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideItemUsed, loc1));
            }
            this.useEquipItem(loc1);
            return;
        }

        /* internal  */onUserEquipFabaoHandler(arg1: DataEvent): void
        {
            if (!cache.magicWeapon.isCanEquipMagicWeapon) 
            {
                MsgManager.showRollTipsMsg(Language.getString(80354));
                return;
            }
            var loc1=arg1.data as ItemData;
            if (this._guideUid && this._guideUid == loc1.uid) 
            {
                this._guideUid = "";
                this._packModule.cacelPackIndexGuide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideItemUsed, loc1));
            }
            GameController.player.dress(loc1.posType, loc1.uid);
            return;
        }

        /* internal  */onIdentifyFabaoHandler(arg1: DataEvent): void
        {
            if (!cache.magicWeapon.isCanIdentifyMagicWeapon) 
            {
                MsgManager.showRollTipsMsg(Language.getString(80353));
                return;
            }
            var loc1=arg1.data as ItemData;
            if (!loc1.isHasIdentify()) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MagicWeaponShowView, loc1));
            }
            return;
        }

        /* internal  */onUserEquipMountHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (this._guideUid && this._guideUid == loc1.uid) 
            {
                this._guideUid = "";
                this._packModule.cacelPackIndexGuide();
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideItemUsed, loc1));
            }
            this.equipMount(loc1);
            return;
        }

        /* internal  */itemUseReq(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            var loc2=loc1.uid;
            var loc3=Cache.instance.pack.backPackCache.getIndexByUid(loc1.uid);
            if (loc1) 
            {
                if (loc1.itemInfo.item.category != ECategory._ECategoryEquip) 
                {
                    if (loc1.itemInfo.item.category != ECategory._ECategoryJewel) 
                    {
                        this.useItem(loc1);
                    }
                    else 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Show, loc1));
                    }
                }
                else 
                {
                    this.useEquipItem(loc1);
                }
            }
            return;
        }

        /* internal  */destroy(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            this._packProxy.remove(loc1.uid, loc1.posType);
            return;
        }

        /* internal  */onTradeStatusChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onMarketSellStatusChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onMarketBuyWindowStatusChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onGuideItemStrengthenChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onPetEggsChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onMainStatusChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onStallStatusChange(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */onGuildWarehouseOpen(arg1: DataEvent): void
        {
            this.updatePack();
            return;
        }

        /* internal  */get packModule(): IPackModule
        {
            return this._packModule;
        }

        /* internal  */dragInExtendItem(arg1: DataEvent): void
        {
            var loc2=0;
            var loc3=0;
            var loc1=arg1.data as DragDropData;
            var loc4=loc1.fromPosType;
            switch (loc4) 
            {
                case EPlayerItemPosType._EPlayerItemPosTypeBag:
                {
                    loc2 = loc1.fromIndex + this.pageSize * this._packModule.pageTabBarSelect;
                    loc1.fromIndex = loc2;
                    this.moveExtendItem(loc1, this._packCache);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWarehouse:
                {
                    loc2 = loc1.fromIndex + this.pageSize * (GameController.wareHouse.view as IWareHouseModule).pageTabBarSelect;
                    loc1.fromIndex = loc2;
                    this.moveExtendItem(loc1, this._packCache);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar:
                {
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar:
                {
                    loc2 = loc1.fromIndex;
                    loc1.fromIndex = loc2;
                    if (loc3 <= Cache.instance.pack.backPackExtendPackCache.sbag.capacity) 
                    {
                        this._packExtendProxy.moveInBag(loc1);
                    }
                    break;
                }
            }
            return;
        }

        /* internal  */updateCapacityChange(arg1: Object): void
        {
            var loc1=Cache.instance.pack.backPackCache.capacity;
            var loc2=arg1 as SBagCapacityChangeMsg;
            var loc3=Math.abs(loc2.newCapacity - loc1);
            if (loc2.newCapacity > loc1) 
            {
                Cache.instance.pack.backPackCache.addNullItemToEnd(loc3);
                this.updatePack();
            }
            Cache.instance.pack.backPackCache.capacity = loc2.newCapacity;
            this._packModule.updateCapacity();
            return;
        }

        /* internal  */moveExtendItem(arg1: DragDropData, arg2): void
        {
            var dragDropData: DragDropData;
            var proxy;
            var len: int;
            var toItemIsExtend: Boolean;
            var _cache;
            var _proxy;
            var toItemCategory: int;
            var toItemProp: int;
            var toItemData: ItemData;
            var fromItemData: ItemData;
            var fromIndex: int;
            var toIndex: int;
            var fromPosType: int;
            var toPosType: int;
            var uid: string;
            var isTidy: Boolean;
            var pathOfDrag: string;
            var showAlterWindow: Function;
            var fromItemEffect: int;
            var toItemEffect: int;

            var loc1;
            len = 0;
            toItemIsExtend = false;
            _cache = undefined;
            _proxy = undefined;
            toItemCategory = 0;
            toItemProp = 0;
            toIndex = 0;
            isTidy = false;
            pathOfDrag = null;
            fromItemEffect = 0;
            toItemEffect = 0;
            dragDropData = arg1;
            proxy = arg2;
            showAlterWindow = (arg1: string, arg2: Boolean, arg3: string=null): void
            {
                var posName: string;
                var _isTidy: Boolean;
                var path: string=null;
                var closeHandler1: Function;

                var loc1;
                posName = arg1;
                _isTidy = arg2;
                path = arg3;
                if (_cache.getLengthOfNullItemFromAllItem() >= len) 
                {
                    closeHandler1 = (arg1: int): void
                    {
                        if (arg1 == Alert.YES) 
                        {
                            if (toIndex <= _cache.sbag.capacity) 
                            {
                                _proxy.move(dragDropData, _isTidy, path);
                            }
                        }
                        return;
                    }
                    Alert.show(Language.getString(40030) + posName, null, Alert.YES | Alert.CANCEL, null, closeHandler1);
                }
                else 
                {
                    MsgManager.showRollTipsMsg(posName + Language.getString(40031));
                }
                return;
            }
            toItemData = dragDropData.toItemData;
            fromItemData = dragDropData.fromItemData;
            fromIndex = dragDropData.fromIndex;
            toIndex = dragDropData.toIndex;
            fromPosType = dragDropData.fromPosType;
            toPosType = dragDropData.toPosType;
            uid = dragDropData.uid;
            if (!ItemsUtil.isPackage(fromItemData)) 
            {
                return;
            }
            if (toItemData != null) 
            {
                toItemCategory = toItemData.itemInfo.item.category;
                toItemProp = toItemData.itemInfo.item.type;
                fromItemEffect = fromItemData.itemInfo.item.effect;
                toItemEffect = toItemData.itemInfo.item.effect;
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                    if (ItemsUtil.isPackage(toItemData)) 
                    {
                        pathOfDrag = BackPackWareHouseMoveType.BackPackExtendToBackPack;
                        toItemIsExtend = true;
                        len = fromItemEffect - toItemEffect;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBag && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar) 
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                    if (ItemsUtil.isPackage(toItemData)) 
                    {
                        pathOfDrag = BackPackWareHouseMoveType.BackPackToBackPackExtend;
                        toItemIsExtend = true;
                        len = fromItemEffect - toItemEffect;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar) 
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    if (ItemsUtil.isPackage(toItemData)) 
                    {
                        pathOfDrag = BackPackWareHouseMoveType.WareHouseToBackPackExtend;
                        toItemIsExtend = true;
                        len = fromItemEffect - toItemEffect;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                    if (ItemsUtil.isPackage(toItemData)) 
                    {
                        pathOfDrag = BackPackWareHouseMoveType.WareHouseExtendToBackPack;
                        toItemIsExtend = true;
                        len = fromItemEffect - toItemEffect;
                    }
                }
            }
            else 
            {
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar) 
                {
                    GameProxy.packExtendProxy.move(dragDropData);
                    return;
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBag && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar) 
                {
                    GameProxy.packExtendProxy.move(dragDropData);
                    return;
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                    toItemIsExtend = false;
                    len = fromItemData.itemInfo.item.effect + 1;
                    showAlterWindow(Language.getString(40028), true);
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    toItemIsExtend = false;
                    len = fromItemData.itemInfo.item.effect + 1;
                    showAlterWindow(Language.getString(40029), true, BackPackWareHouseMoveType.WareHouseExtendToBackPack);
                }
            }
            if (!pathOfDrag) 
            {
                return;
            }
            var loc2=pathOfDrag;
            switch (loc2) 
            {
                case BackPackWareHouseMoveType.BackPackToBackPackExtend:
                {
                    if (toIndex <= _cache.sbag.capacity) 
                    {
                        if (len >= 0) 
                        {
                            isTidy = false;
                            _proxy.move(dragDropData);
                        }
                        else 
                        {
                            isTidy = true;
                            showAlterWindow(Language.getString(40028), isTidy);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.BackPackExtendToBackPack:
                {
                    if (toIndex <= _cache.sbag.capacity) 
                    {
                        if (len > 0) 
                        {
                            isTidy = true;
                            showAlterWindow(Language.getString(40028), isTidy);
                        }
                        else 
                        {
                            isTidy = false;
                            _proxy.move(dragDropData);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.WareHouseToBackPackExtend:
                {
                    if (toIndex <= _cache.sbag.capacity) 
                    {
                        if (len > 0) 
                        {
                            isTidy = false;
                            _proxy.move(dragDropData);
                        }
                        else 
                        {
                            isTidy = true;
                            showAlterWindow(Language.getString(40028), isTidy, BackPackWareHouseMoveType.WareHouseToBackPackExtend);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.WareHouseExtendToBackPack:
                {
                    if (toIndex <= _cache.sbag.capacity) 
                    {
                        if (len > 0) 
                        {
                            isTidy = true;
                            showAlterWindow(Language.getString(40029), isTidy, BackPackWareHouseMoveType.WareHouseExtendToBackPack);
                        }
                        else 
                        {
                            isTidy = false;
                            _proxy.move(dragDropData);
                        }
                    }
                    break;
                }
            }
            return;
        }

        private /* const */pageSize: int=42;

        private /* var */_packModule: IPackModule;

        private /* var */_packProxy: PackProxy;

        private /* var */_packCache: PackPosTypeCache;

        private /* var */_packExtendProxy: PackExtendProxy;

        private /* var */_page: int;

        public /* var */isBloodItemUseing: Boolean=false;

        public /* var */isManaItemUseing: Boolean=false;

        public /* var */autoUse: Boolean=true;

        public /* var */autoUseSendToServer: Boolean=true;

        private /* var */_isActiveOpen: Boolean;

        private /* var */lightMask: LightMask;

        private /* var */_guideUid: string;

        private /* var */isFull: Boolean=false;

        private /* var */_tips: GuideTips;

        private /* var */_packWallet: PackWallet;
    }
